package com.mszlu.blog.handler;

import com.mszlu.blog.vo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Package: com.mszlu.blog.handler
 * @ClassName: AllExceptionHanlder
 * @Author: 陈威
 * @CreateTime: 2021/8/29 15:06
 * @Description:
 */
//对加了@controller注解的类进行异常拦截 aop的实现
@ControllerAdvice
public class AllExceptionHanlder {

    //进行异常处理 处理Exception.class的异常
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result doException(Exception ex){
        ex.printStackTrace();
        return Result.fail(-999,"系统异常");
    }
}